<%#*plugin events details index page%>
<html>
  <head>
   
    <title>Events Detail</title>

    <link href="/stylesheets/tab_default.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="/stylesheets/calendar/blue/style.css">


    <script type='text/javascript'>

      function load_calendar(year,month)
      {
        if(month=="13"){
          month=1
          year=parseInt(year)+1
        }
        if(month=="0"){
          month="12"
          year=parseInt(year)-1
        }


        location.href='/calendar_clients/detail_page?timeframe=month&date='+year+'-'+month+'-1';
      }

      function displaymessage(cellText,date)
      {

        location.href="/calendar_clients/detail_page?timeframe=day&date="+date
      <%#*tooltip=get_details(cellText,"")%>

      <%#*document.getElementById("detail_view").innerHTML=tooltip;%>
       }




  function cellOver(cellOb,cellText)
  {
    tooltip=get_details(cellText,"")

    <%#*document.getElementById("detail_view").innerHTML=tooltip;%>

  }

  function week_filter(date){

    location.href="/calendar_clients/detail_page?timeframe=week&date="+date;
  }


  function get_details(cellText,filter_type)
  {

    var html_text="";

    var temp="<%Date.parse("2000-1-1")%>";

    <%@event_ob.sort_by {|u| u.start}.each{|r|%>

      <%dateTimeStart=DateTime.parse(r.start.to_s)%>
      <%dateTimeEnd=DateTime.parse(r.end.to_s)%>

      var month_day="<%=dateTimeStart.mday%>";


      var event_type="Others"
      <%if not r.event_type.nil? %>
            event_type='<%=r.event_type%>'
      <%end%>

      if(filter_type==event_type | filter_type=="all" ){


         if(cellText=="" || month_day==cellText){

            var temp_start="<%=Date.parse(r.start.to_s)%>";

            if(temp!=temp_start){
                html_text=html_text+"<hr><font size='3' color='#680000'><b><%=dateTimeStart.strftime("%A %B %d %Y") %></b></font><br>";
            }

            var web_link="";


            <%if r.highlight=="true" and !(r.webpage.nil? or r.webpage.empty?)  %>

                 web_link="<a href='#' onClick=window.open('<%=r.webpage %>','','') ><font color='blue' style='font-size:10px;' > Book Now</font></a>";

            <%end%>

            if (event_type=="film"){

                html_text=html_text+"<font size='2'><b><%=r.title %>"+web_link+
                  "</b><br><%=r.event_type.to_s %> | Location : "+
                  "<%=r.where %> | Description : <%=r.content.to_s %></font><br><br>"

            }
            else{
                if(event_type=="holiday"){
                       html_text=html_text+"<font size='2'><b> <%=r.title %></b><br><br>"
                }else{
                  html_text=html_text+"<font size='2'><b><%=r.title %>"+web_link+
                  "</b><br> <%=r.event_type.to_s %> | <%=dateTimeStart.strftime("%I:%M%p") %>"+
                  "<%=dateTimeEnd.strftime(" to %I:%M%p") %> |   Location : "+
                  "<%=r.where %> | Description : <%=r.content.to_s %></font><br><br>"
                }
             }

             temp="<%=Date.parse(r.start.to_s)%>";

          }
       }

    <%} if not @event_ob.nil?%>
    if(html_text==""){
        return "<hr><b>No Events</b>";
    }else{
        return html_text;
    }

  }

function cellOver(cellOb,cellText)
    {
      var tooltip="";
      var films="";
      var others="";
      var holidays="";

<%@tooltip_ob.sort_by {|u| u.start}.each{|r|%>

  <%dateTimeStart=DateTime.parse(r.start.to_s)%>
  <%dateTimeEnd=DateTime.parse(r.end.to_s)%>

      var cell="<%=dateTimeStart.mday%>";

      if(cell==cellText){


  <%if r.event_type=="film"%>
          films=films+"<font size='2'><b> <%=r.title %></b><br> "+

            " Description : <%=r.content.to_s %></font><br><br>"

  <%else%>

     <%if r.event_type=="holiday"%>
          holidays=holidays+"<font size='2'><b> <%=r.title %></b><br><br>"

    <%else%>

            others=others+"<font size='2'><b><%=dateTimeStart.strftime("%I:%M%p") %>"+
            "<%=dateTimeEnd.strftime(" to %I:%M%p") %> : <%=r.title %></b><br> Location : "+
            "<%=r.where %><br> Description : <%=r.content.to_s %></font><br><br>"
    <%end%>


  <%end%>



      }
<%} if not @tooltip_ob.nil? %>

    if (holidays!=""){
      tooltip=tooltip+"<font size='3' STYLE='text-decoration:underline'><b>Holidays</b></font><br>"+holidays
    }

    if (films!=""){
      tooltip=tooltip+"<font size='3' STYLE='text-decoration:underline'><b>Films</b></font><br>"+films
    }
    if (others!=""){
      tooltip=tooltip+"<font size='3' STYLE='text-decoration:underline'><b>Parties,Concerts and Others</b></font><br>"+others
    }

    if(tooltip!=""){
      Tip(tooltip);
    }



<%#*cellOb.style.backgroundColor='#ffffff';%>

  }




  function colorChangeOut(cellOb)
  {
<%#*hideddrivetip();%>
<%#*cellOb.style.backgroundColor='red'%>

  }

  function display_filter_result(tab,type){

    document.getElementById('tab1').setAttribute("class", "");
    document.getElementById('tab2').setAttribute("class", "");
    document.getElementById('tab3').setAttribute("class", "");
    document.getElementById('tab4').setAttribute("class", "");
    document.getElementById('tab5').setAttribute("class", "");

    <%#*for IE%>
    document.getElementById('tab1').className = "";
    document.getElementById('tab2').className = "";
    document.getElementById('tab3').className = "";
    document.getElementById('tab4').className = "";
    document.getElementById('tab5').className = "";


    document.getElementById(tab.id).setAttribute("class", "active");
    document.getElementById(tab.id).className = "active";


    var de=get_details('',type);
    document.getElementById("content").innerHTML=de

  }




    </script>



  </head>
  <body>
    


<%= javascript_include_tag "events_calendar_js/wz_tooltip"   %>
    <%#*<script LANGUAGE="JavaScript" SRC="javascripts/events_calendar_js/tooltip.js"></script>%>

    <h1 style="font-size:20px; font-weight:bold; padding:4px 12px;">Events Calendar</h1>

    <table border="1" style="border-color:black" >


      <tr style="background-color:#F0F0F0 ">
        <td height="300" width="250" align="center" valign="top" style="background-color:#F0F0F0;vertical-align:top">
          <div align="left" style="background-color:#F0F0F0;height:auto">
            <%=calendar(:previous_month_text   => "&lt;&lt;Prev",:next_month_text   =>"Next&gt;&gt;",:year => @year.to_i, :month => @month.to_i, :detail_view=>"true") do |d|


               types=[]
               @events_details.each{|key,value|
                  if not @events_details[key]["array"].nil? and @events_details[key]["array"].include?(d)

                       types.push(key)
                   end

               } if not @events_details.nil?


               case(types.size)
               when 0

                when 1
                
                 if types.include?("holiday")

                  if d.wday==0 or d.wday==6
                    [d.mday, {:class => "day weekendDay",:style=>"background-image: url(/images/calendar_images/holiday_star.gif);background-repeat:no-repeat"}]
                  else
                    [d.mday, {:class => "day",:style=>"background-image: url(/images/calendar_images/holiday_star.gif);background-repeat:no-repeat"}]
                  end

                 else
                   colour=@events_details[types[0]]["colour"]
                   [d.mday, {:class => "specialDay",:style=>"background-color:#{colour}"}]
                 end

                when 2
                                     
                    if types.include?("holiday")
                        if types[0]=="holiday"
                          colour=@events_details[types[1]]["colour"]
                        else
                          colour=@events_details[types[0]]["colour"]
                        end
                       [d.mday, {:class => "specialDay",:style=>"background-color:#{colour};background-image:url(/images/calendar_images/holiday_star.gif);background-repeat:no-repeat"}]
                    else
                      [d.mday, {:class => "film_and_event"}]
                    end

               else                    
                    if types.include?("holiday")

                      [d.mday, {:class => "mixed_events_and_holiday"}]
                    else
                      [d.mday, {:class => "film_and_event"}]
                    end


               end

             
            end

          %>
              <ul style="font-size:11px">
              <li style="color:blue">&yen; Today
              <li style="color:#FFCC33"><img width="10" height="10" src="/images/calendar_images/holiday_star.gif">Holidays
            </ul>

            <div class="filters" style="background-color:#F0F0F0">

            <hr>
              <a href="/calendar_clients/detail_page?timeframe=day&date=<%=Date.today.to_s%>" >Today's events</a><hr>
              <a href="/calendar_clients/detail_page?timeframe=week&date=<%=Date.today.to_s%>" >This week's events</a><hr>
              <a href="/calendar_clients/detail_page?timeframe=month&date=<%=Date.today.to_s%>" >This month's events</a><hr>
            </div>

          </div>
        </td>



        <td align="left" valign="top" width="650" style="background-color:#F0F0F0;vertical-align:top">

          <div id="t_container">
            <div id="tabs_container">
              <ul id="tabmenu">

                <li> <a onclick="display_filter_result(this,'all')" class="active" id="tab1" >All Events</a> </li>
                <li><a onclick="display_filter_result(this,'film')" id="tab2" > Films </a></li>
                <li><a onclick="display_filter_result(this,'party')" id="tab3" > Parties </a></li>
                <li><a onclick="display_filter_result(this,'concert')" id="tab4" > Concerts </a></li>
                <li><a onclick="display_filter_result(this,'other')" id="tab5" >Other Events</a></li>
              </ul>
              <div id="content">
                <script type='text/javascript'>
                 
                  document.write(get_details("","all"));
                </script>

              </div>

            </div>
          </div>




        </td>
      </tr>



    </table>



  </body>
</html>